<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>title</title>
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../css/api.css"/>
		<style>
			body {
				background: #FFFFFF;
				margin: 0px;
			}
			.item {
				width: 100%;
				height: 39px;
				line-height: 39px;
				display: -webkit-box;
			}
			.item img {
				height: 8px;
				padding-left: 40px;
				padding-right: 15px;
				padding-bottom: 2px;
			}

			.item_text {
				font-size: 13px;
				display: block;
				-webkit-margin-before: 0em;
				-webkit-margin-after: 0em;
				-webkit-margin-start: 0px;
				-webkit-margin-end: 0px;
			}
			li {
				list-style-type: none;
				height: auto;
				width: 100%;
			}
			
			ul {
				display: block;
				list-style-type: disc;
				-webkit-margin-before: 0em;
				-webkit-margin-after: 0em;
				-webkit-margin-start: 0px;
				-webkit-margin-end: 0px;
				-webkit-padding-start: 0px;
			}
		</style>
	</head>
	<body>
		<div id="list_type">
			<!--<li>
				<div class="item" onclick="checkli(' + i + ')">
					<img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" />
					<p class="item_text">
						分类
					</p>
				</div>
				<div class="div_divider"></div>
			</li>-->
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/mui.min.js"></script>
	<script type="text/javascript">
		var type_list = new Object();
		var type = "";
		var types = [];
		var lx = "";
		var fx = "";
		var cj = "";
		var xl = "";
		apiready = function() {
			type = api.pageParam.type;
			
			loadData();
		};
		//获取方向、层级、序列的选项数据
		function loadData() {
			var data = $api.getStorage("top_type");
			if(data == "null"){
				api.closeFrame({
                });
				api.toast({
	                msg:'数据请求出错！！！'
                });
			}else{
				type_list = data;
//				alert(111);
			
				writelist();
			}
		}

		function writelist() {
			var list_date = "";
			list_date = list_date + "<ul>";
			types = [];
			if (type == "0") {
				var ssd = type_list.data.type;
				for (var i = 0; i < ssd.length; i++) {
					var item = {};
					item.name = type_list.data.type[i];
					types.push(item);
				}
				 
				if ($api.getStorage("lx") == "") {
					for (var i = 0; i < types.length; i++) {
						if (i == 0) {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigou.png" /> <p class="item_text base_style_text_color">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						} else {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						}
					}
				} else {
					for (var i = 0; i < types.length; i++) {
						if (types[i].name == $api.getStorage("lx")) {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigou.png" /> <p class="item_text base_style_text_color">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						} else {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						}
					}
				}
			}
			if (type == "1") {
				var items = {};
				items.name = "全部";
				types.push(items);
				var ssd = type_list.data.quarter_direction;
				for (var i = 0; i < ssd.length; i++) {
					var item = {};
					item.name = type_list.data.quarter_direction[i];
					types.push(item);
				}
				if ($api.getStorage("fx") == "") {
					for (var i = 0; i < types.length; i++) {
						if (i == 0) {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigou.png" /> <p class="item_text base_style_text_color">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						} else {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						}
					}
				} else {
					for (var i = 0; i < types.length; i++) {
						if (types[i].name == $api.getStorage("fx")) {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigou.png" /> <p class="item_text base_style_text_color">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						} else {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						}
					}
				}
			}
			if (type == "2") {
				var items = {};
				items.name = "全部";
				types.push(items);
				var ssd = type_list.data.quarter_rank;
				for (var i = 0; i < ssd.length; i++) {
					var item = {};
					item.name = type_list.data.quarter_rank[i];
					types.push(item);
				}
				if ($api.getStorage("cj") == "") {
					for (var i = 0; i < types.length; i++) {
						if (i == 0) {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigou.png" /> <p class="item_text base_style_text_color">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						} else {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						}
					}
				} else {
					for (var i = 0; i < types.length; i++) {
						if (types[i].name == $api.getStorage("cj")) {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigou.png" /> <p class="item_text base_style_text_color">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						} else {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						}
					}
				}
			}
			if (type == "3") {
				var items = {};
				items.name = "全部";
				types.push(items);
				var ssd = type_list.data.quarter_order;
				for (var i = 0; i < ssd.length; i++) {
					var item = {};
					item.name = type_list.data.quarter_order[i];
					types.push(item);
				}
				if ($api.getStorage("xl") == "") {
					for (var i = 0; i < types.length; i++) {
						if (i == 0) {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigou.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider base_style_text_color"></div> </li>';
						} else {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						}
					}
				} else {
					for (var i = 0; i < types.length; i++) {
						if (types[i].name == $api.getStorage("xl")) {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigou.png" /> <p class="item_text base_style_text_color">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						} else {
							list_date = list_date + '<li> <div class="item" onclick="checkli(' + i + ')"> <img id="gwtype' + i + '" src="../../icon/icon_duigoub.png" /> <p class="item_text">' + types[i].name + '</p> </div> <div class="div_divider"></div> </li>';
						}
					}
				}
			}
			list_date = list_date + "</ul>";
			x = document.getElementById("list_type");
			x.innerHTML = list_date;
		}

		function checkli(ids) {
			//更改item中图片
			for (var i = 0; i < types.length; i++) {
				$("#gwtype" + i).attr("src", "../../icon/icon_duigoub.png");
			}
			$("#gwtype" + ids).attr("src", "../../icon/icon_duigou.png");
			var arr=new Array();
			// 保存选中的选项
			if (type == "0") {
				lx = types[ids].name;
				arr[0]= {
                 name: types[ids].name,
                id: ids + 1,
                
                }
				$api.setStorage("lx",lx);

			}
			if (type == "1") {//方向
				fx = types[ids].name;
				arr[1]= {
                  name: types[ids].name,
                  id: ids,
             
                }
                $api.setStorage("fx",fx);
//			alert(2);
//				if(ids == 0){
//					$api.setStorage("quarter_directions","");
//				}else{
//					$api.setStorage("quarter_directions",ids);
//				}
				
			}
			if (type == "2") {//层级
//			alert(3);
				cj = types[ids].name;
				arr[2]= {
                  name: types[ids].name,
                  id: ids,
                }
				$api.setStorage("cj",cj);
//				if(ids == 0){
//					$api.setStorage("quarter_ranks","");
//				}else{
//					$api.setStorage("quarter_ranks",ids);
//				}
			}
			if (type == "3") {//序列
//			alert(4);
				xl = types[ids].name;
				arr[3]= {
                  name: types[ids].name,
                  id: ids,
               
                }
				$api.setStorage("xl",xl);
//				if(ids == 0){
//					$api.setStorage("quarter_orders","");
//				}else{
//					$api.setStorage("quarter_orders",ids);
//				}
			}
			//关闭frame
			api.sendEvent({
				name : 'mark_close'
			});
			api.sendEvent({
				name : 'close_mask'
			});

	    api.sendEvent({
	     name: 'item_point',
	     extra: {
	        data: arr,
	        type:type
	    }
       });
		}
	</script>
</html>